<template>
  <div class="app-container">
      <div class="filter-container">

         <el-select v-model="filters.feedback_type_id"  :clearable="true" placeholder="请选择">
          <el-option
          
            v-for="item in feedbackTypeIdOptions"
            :key="item.value"
            :label="item.text"
            :value="item.value">
          </el-option>
        </el-select>
      
        <el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="反馈人电话" v-model="filters['user.telephone']"></el-input>

        <el-date-picker style="width: 200px;" class="filter-item" value-format="yyyy-MM-dd" v-model="filters.gt$create_time_start" type="date" placeholder="选择开始日期"></el-date-picker>
        <el-date-picker style="width: 200px;" class="filter-item" value-format="yyyy-MM-dd" v-model="filters.lt$create_time_end" type="date" placeholder="选择结束日期"></el-date-picker>
      
        <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">搜索</el-button>
        <el-button class="filter-item" type="primary" v-if="~accessable.indexOf('feedback:manage_export')" v-waves icon="el-icon-document" @click="exportExcelFile">导出</el-button>
      </div>
      <el-table :height="tableHeight" :data="list" @sort-change="sortChange" v-loading="listLoading" element-loading-text="给我一点时间" border fit highlight-current-row
      style="width: 100%">
        <el-table-column align="center" type="index" label="序号" width="80">
        </el-table-column>

        
        
        <el-table-column  prop="nickname" align="center" label="反馈人" width="120">
          <template slot-scope="scope">
            <span>{{scope.row.nickname}}</span>
          </template>
        </el-table-column>
        <el-table-column  prop="telephone" align="center" label="反馈人电话" width="120">
          <template slot-scope="scope">
            <span>{{scope.row.telephone}}</span>
          </template>
        </el-table-column>
        
        
        <el-table-column  prop="feedback_typeName" align="center" label="反馈类型" width="120">
          <template slot-scope="scope">
            <span>{{scope.row.feedback_typeName}}</span>
          </template>
        </el-table-column>
        
        
        <el-table-column  prop="content" align="center" label="反馈内容" width="300">
          <template slot-scope="scope">
            <span>{{scope.row.content}}</span>
          </template>
        </el-table-column>
        
        
        <el-table-column  prop="imgSrcs" align="center" label="图片" width="180">
          <template slot-scope="scope">
            <div v-if="scope.row.imgSrcs">
              <img :src="img|absUrl" v-for="(img,idx) in scope.row.imgSrcs.split(',')" :key="idx" alt="" style="max-width:100px;">
            </div>
          </template>
        </el-table-column>
        
        
        <el-table-column  prop="contacts" align="center" label="联系方式" width="160">
          <template slot-scope="scope">
            <span>{{scope.row.contacts}}</span>
          </template>
        </el-table-column>
        
        
        <el-table-column  prop="createTime" align="center" label="反馈时间" width="160">
          <template slot-scope="scope">
            <span>{{scope.row.createTime}}</span>
          </template>
        </el-table-column>
        <el-table-column  prop="reply" align="center" label="回复内容" width="160">
          <template slot-scope="scope">
            <span>{{scope.row.reply}}</span>
          </template>
        </el-table-column>
        
        <el-table-column  prop="reply" align="center" label="回复时间" width="160">
          <template slot-scope="scope">
            <span>{{scope.row.replyTime}}</span>
          </template>
        </el-table-column>
        
        
        <el-table-column align="center" label="操作" width="200" class-name="small-padding">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" v-if="~accessable.indexOf('feedback:manage_reply')" @click="handleUpdate(scope.row)">回复</el-button>          
            <el-button size="mini" type="danger" v-if="~accessable.indexOf('feedback:manage_delete')" @click="handleDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination-container">
      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="params.page"
        :page-sizes="[10,20,30,50]" :page-size="params.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </div>

    <el-dialog title="回复" :visible.sync="dialogFormVisible">
      <el-form class="dialog-form" :rules="rules" ref="dataForm" :model="temp" label-position="left" label-width="120px">
        
        <el-form-item label="反馈人">          
            
                                  
                {{temp.nickname}}
            
        </el-form-item>         
        
        <el-form-item label="反馈类型">          
            
              {{temp.feedback_typeName}}
            
        </el-form-item>         
        
        <el-form-item label="反馈内容">          
               {{temp.content}}
                                  
            
        </el-form-item>         
        
        <el-form-item label="图片">          
             <div v-if="temp.imgSrcs">
              <img :src="img|absUrl" v-for="(img,idx) in temp.imgSrcs.split(',')" :key="idx" alt="" style="max-width:100px;">
            </div>
            
        </el-form-item>         
        
        <el-form-item label="联系方式">          
                {{temp.contacts}}
        </el-form-item>         
        <el-form-item label="回复内容" prop="reply">          
             <el-input
  type="textarea"
  :rows="5"
  placeholder="请输入回复内容"
  v-model="temp.reply">
</el-input>
                
        </el-form-item>         
                         
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取消</el-button>
        <el-button type="primary" :loading="submiting" @click="submitFormAction">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>

export default {
  data() {
    return {
      total:0,
      tableHeight:400,
      temp:{
          
          id:'',
          
          nickname:'',
          
          feedback_typeName:'',
          
          content:'',
          
          imgSrcs:'',
          
          contacts:'',
          reply:''
          
      },
      
            feedbackTypeIdOptions:[],
            
      rules: {
        
          
        
        reply: [
          
          { required: true, message: "回复内容不能为空", trigger: "change"},
          { max: 200, message: "回复内容不能多余200个字", trigger: "change"}
          
        ],        
        
      }
    };
  },
  created() {
    this.init("feedback",1).loadData();

    
    this.combOptions('feedback_type').then(info=>{
        this.feedbackTypeIdOptions = info;
    });
       this.tableHeight = window.innerHeight - 300;   

    
  },
  filters: {

  },
  methods: {
    exportExcelFile() {
      this.exportExcel({
        title: "留言反馈",
        fields: [
          
            
            {field:'nickname',title:'反馈人'}
          
            ,
            {field:'feedback_typeName',title:'反馈类型'}
            ,
            {field:'telephone',title:'反馈手机号'}
          
            ,
            {field:'content',title:'反馈内容'}
          
        
          
            ,
            {field:'contacts',title:'联系方式'}
          
            ,
            {field:'createTime',title:'反馈时间'}
            ,
            {field:'reply',title:'回复内容'}
            ,
            {field:'replyTime',title:'回复时间'}
          
        ]
      }).then(info => {
        this.openWin(info);        
      });
    }
  }
};
</script>
